﻿!(function ($) {
    $.fn.category = function (opts) {
        return this.each(function () {
            var defaults = { url: "", site: "", id: "" }
            var options = $.extend(defaults, opts);
            var $thisDiv = $(this).addClass("ds-category ").prop("id", "category_id");
            //var $div=$("<div></div>").addClass("scroller");
            var $ul = $("<ul></ul>").addClass("feed ");

            $.getJSON(options.url, { id: options.id, site: options.site }, function (data) {
                if (data.length > 0) {
                    $.each(data, function (i, d) {
                        var $li = $("<li value='" + d.value + "'></li>");
                        var $a = $("<a href='#'>" + d.text + "</a>");
                        $li.append($a);
                        if (d.next == true || d.next == "true") {
                            var $em = $("<em class='icon-caret-right'></em>");
                            $li.append($em);
                        }
                        $ul.append($li);
                    });
                }
            });
        });
    }
})(jQuery)